{% extends 'users/user-base.html' %}

{% load static %}
{% block title %}级联审核{% endblock %}
{% block custom_css %}
    <style>
        td{
            vertical-align:middle !important;
        }
    </style>
{% endblock %}

{% block custom_js %}{% endblock %}

{% block contentNodeapply %}
    <script type="text/javascript">
        $(document).ready(function () {
            $("#tab").on("click", ":button", function (event) {
                var btn_id = $(this).attr('id');
                var ip = $(this).closest("tr").find("td").eq(1).text();
                if (btn_id = 'apply_cascade'){
                    $.ajax({
                        type: "POST",
                        data: {
                            'ip': ip,
                        },
                        url: "/admins/agree_cascade/",
                        success: function (data) {
                            if (data["st"] == 1){
                                $("#tipbody").text("同意申请");
                                $("#tipModal").modal("show");
                                $("#tipButton").bind("click", function(){
                                    window.location.reload();
                                })
                            }else{
                                $("#tipbody").text("申请失败");
                                $("#tipModal").modal("show");
                            }
                        },
                        error: function () {
                            $("#tipbody").text("申请失败，请请重新确定信息");
                            $("#tipModal").modal("show");
                        }
                    })

                } 
            });
        })
    </script>

        <div class="dashboard-wrapper">
            <div class="dashboard-ecommerce">
                <div class="container-fluid dashboard-content ">
                    <!-- ============================================================== -->
                    <!-- pageheader  -->
                    <!-- ============================================================== -->
                    <div class="row">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="page-header">
                                <h2 class="pageheader-title">级联审核</h2>
                                <div class="page-breadcrumb">
                                    <nav aria-label="breadcrumb">
                                        <ol class="breadcrumb">
                                            <li class="breadcrumb-item">域管理</li>
                                            <li class="breadcrumb-item active" aria-current="page">级联审核</li>
                                        </ol>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- ============================================================== -->
                    <!-- end pageheader  -->
                    <!-- ============================================================== -->

                    <div class="row">
                        <!-- ============================================================== -->
                        <!-- basic table  -->
                        <!-- ============================================================== -->
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="card">
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered first" id="tab">
                                            <thead>
                                            <tr>
                                                <th >ID</th>
                                                <th >平台IP</th>
                                                <th >平台端口</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <form id="cascade_apply_form">
                                                {% for apply in cascade_list %}
                                                    <tr>
                                                        <td>{{ forloop.counter }}</td>
                                                        <td>{{ apply.ip }}</td>
                                                        <td>{{ apply.port }}</td>
                                                        <td>
                                                            <button type="button" class="btn btn-success" id="apply_cascade">
                                                                <span class="glyphicon glyphicon-ok"></span>
                                                                同意
                                                            </button>
                                                    </tr>
                                                {% endfor %}
                                            </form>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


{% endblock %}
